<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MdiWin Demo - edit</title>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/data/yqwin.min" cache="false"></uieip>
</head>

<body>
    <h1>yqTextTree</h1>
    <input id="dg" type="text" style="width:280px;">
    <p></p>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:setData2()">setData</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:clearData2()">clear</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:getData2()">getData</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:newLoad2()">newLoad</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:isEdit2(true)">isEdit==true</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:isEdit2(false)">isEdit==false</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:destroy2()">destroy</a>
    <!--
    <input id="txt_width" value="280" style="width:120px;">
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:destroy()">destroy</a>
    -->

    <h2>yqTreeEdit</h2>
    <table id="tb2" style="width:100%;height: 400px;">
    </table>

    <p></p>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:setData()">setData</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:clearData()">clear</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:getData()">getData</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:newLoad()">newLoad</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:isEdit(true)">isEdit==true</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:isEdit(false)">isEdit==false</a>
    <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:destroy()">destroy</a>
    <script>
        $(function () {
            $('#tb2').yqTreeEdit({
                ajaxUrl: "",
                displayMember: "name",          //显示字段
                titles: mytitles,  //数据列配置对象
                data: mytree,
                editModeW: 600, //模态编辑器宽度 格式为 800（数字）
                editModeH: 350, //模态编辑器高度 格式为 600（数字）
                isEdit: true,
                beforBindingTitle: function (titles, callback) {
                    console.log("beforBindingTitle", titles);
                    callback(titles);
                }, //标题绑定前
                afterBindingTitle: function () {
                    console.log("afterBindingTitle");
                },   //标题绑定后
                beforeAdd: function (rows, row, callback) {
                    console.log("beforeAdd", rows, row);
                    callback(row);
                },
                endEditing: function (index, row) {   //ok.....
                    console.log("endEditing", index, row);
                },
            });

            $('#dg').yqTextTree({
                ajaxUrl: "",
                displayMember: "name",          //显示字段
                titles: mytitles,  //数据列配置对象
                data: mytree,
                editModeW: 500, //模态编辑器宽度 格式为 800（数字）
                editModeH: 300, //模态编辑器高度 格式为 600（数字）
                isEdit: true,
                beforBindingTitle: function (titles, callback) {
                    console.log("beforBindingTitle2", titles);
                    callback(titles);
                }, //标题绑定前
                afterBindingTitle: function () {
                    console.log("afterBindingTitle2");
                },   //标题绑定后
                beforeAdd: function (rows, row, callback) {
                    console.log("beforeAdd2", rows, row);
                    callback(row);
                },
                beforeChange: function (rows, callback) {  //弹出修改前校验
                    console.log("beforeChange2", rows);
                    callback(true, rows);
                },
                afterChange: function (rows) {
                    console.log("afterChange2", rows);
                }
            });
        })

        function setData() {
            $('#tb2').yqTreeEdit("setData", mytree_2);
        }
        function clearData() {
            $('#tb2').yqTreeEdit("clear");
        }
        function getData() {
            var data = $('#tb2').yqTreeEdit("getData");
            console.log(data);
            console.log(JSON.stringify(data,null,4));
        }
        function newLoad() {
            $('#tb2').yqTreeEdit({
                titles: mytitles_2,
                data: mytree_2,
                editModeW: 600,
                editModeH: 400
            });
        }
        function isEdit(tf) {
            $('#tb2').yqTreeEdit("isEdit", tf);
        }
        function destroy() {
            $('#tb2').yqTreeEdit("destroy");
        }
        //---------------------------------------------------
        function setData2() {
            $('#dg').yqTextTree("setData", mytree_2);
        }
        function clearData2() {
            $('#dg').yqTextTree("clear");
        }
        function getData2() {
            var data = $('#dg').yqTextTree("getData");
            console.log(data);
            console.log(JSON.stringify(data,null,4));
        }
        function newLoad2() {
            $('#dg').yqTextTree({
                titles: mytitles_2,
                data: mytree_2,
                editModeW: 600,
                editModeH: 400
            });
        }
        function isEdit2(tf) {
            $('#dg').yqTextTree("isEdit", tf);
        }
        function destroy2() {
            $('#dg').yqTextTree("destroy");
        }
        //--------------------------------------------------------

        var mytitles = [
            {
                "name": "no",
                "ui_title": "No",
                "ui_type": 2,
                "ui_width": 90,
                "ui_visible": true,
                "ui_readnnly": false,
                "ui_mask": {}
            }, {
                "name": "name",
                "ui_title": "Name",
                "ui_type": 2,
                "ui_width": 150,
                "ui_visible": true,
                "ui_readnnly": false,
                "ui_mask": {}
            }, {
                "name": "date",
                "ui_title": "Date",
                "ui_type": 12,
                "ui_width": 150,
                "ui_visible": true,
                "ui_readnnly": false,
                "ui_mask": {}
            }, {
                "name": "foreignkey",
                "is_func": false,
                "ui_title": "ForeignKey",
                "fd_type": "nvarchar",
                "length": 36,
                "decimal": 0,
                "ui_type": 14,
                "ui_width": 180,
                "ui_visible": true,
                "ui_readonly": false,
                "ui_mask": {
                    "default": null,
                    "blank": true,
                    "dbName": "yqbase",
                    "tbName": "sys.sys_table",
                    "tempNo": -1,
                    "displayType": 2,
                    "valueMember": "sid",
                    "displayMember": "textbox",
                    "isPage": true,
                    "pageSize": 10,
                    "addWhere": "",
                    "order": "textbox",
                    "panelWidth": 400,
                    "panelHeight": 360,
                    "expandMember": null,
                    "seekNo": -1,
                    "seekModeW": 800,
                    "seekModeH": 600,
                    "mapping": [
                        {
                            "from": "textbox",
                            "to": "foreignkeyVal"
                        }]
                }
            }, {
                "is_func": false,
                "name": "foreignkeyVal",
                "ui_title": "foreignkeyVal",
                "ui_type": 2,
                "ui_width": 140,
                "ui_visible": true,
                "ui_readonly": false,
                "ui_mask": {
                }
            }
        ];

        var mytree = [
            {
                "no": 1,
                "name": "name1",
                "date": "2010-02-09",
                "subs": [{
                    "no": 101,
                    "name": "name101",
                    "date": "2010-02-09",
                    "subs": [{
                        "no": 10101,
                        "name": "name10101",
                        "date": "2010-02-09",
                    }, {
                        "no": 10102,
                        "name": "name10102",
                        "date": "2010-02-09"
                    }, {
                        "no": 10103,
                        "name": "name10103",
                        "date": "2010-02-09"
                    }]
                }, {
                    "no": 102,
                    "name": "name102",
                    "date": "2010-02-09",
                    "subs": [{
                        "no": 10201,
                        "name": "name10201",
                        "size": "56 KB",
                        "date": "2010-02-09"
                    }, {
                        "no": 10202,
                        "name": "name10202",
                        "date": "2010-02-09"
                    }, {
                        "no": 10203,
                        "name": "name10203",
                        "date": "2010-02-09"
                    }]
                }]
            },
            {
                "no": 2,
                "name": "name2",
                "date": "2010-02-09",
                "subs": [{
                    "no": 201,
                    "name": "name201",
                    "date": "2010-02-09",
                    "subs": [{
                        "no": 20101,
                        "name": "name20101",
                        "date": "2010-02-09",
                    }, {
                        "no": 20102,
                        "name": "name20102",
                        "date": "2010-02-09"
                    }, {
                        "no": 20103,
                        "name": "name20103",
                        "date": "2010-02-09"
                    }]
                }, {
                    "no": 202,
                    "name": "name202",
                    "date": "2010-02-09",
                    "subs": [{
                        "no": 20201,
                        "name": "name20201",
                        "size": "56 KB",
                        "date": "2010-02-09"
                    }, {
                        "no": 20202,
                        "name": "name20202",
                        "date": "2010-02-09"
                    }, {
                        "no": 20203,
                        "name": "name20203",
                        "date": "2010-02-09"
                    }]
                }]
            }
        ];

        var mytitles_2 = [
            {
                "name": "no",
                "ui_title": "No",
                "ui_type": 2,
                "ui_width": 90,
                "ui_visible": true,
                "ui_readnnly": false,
                "ui_mask": {}
            }, {
                "name": "name",
                "ui_title": "Name",
                "ui_type": 2,
                "ui_width": 150,
                "ui_visible": true,
                "ui_readnnly": false,
                "ui_mask": {}
            }, {
                "name": "date",
                "ui_title": "Date",
                "ui_type": 12,
                "ui_width": 150,
                "ui_visible": true,
                "ui_readnnly": false,
                "ui_mask": {}
            }, {
                "name": "foreignkey",
                "is_func": false,
                "ui_title": "ForeignKey",
                "fd_type": "nvarchar",
                "length": 36,
                "decimal": 0,
                "ui_type": 7,
                "ui_width": 180,
                "ui_visible": true,
                "ui_readonly": false,
                "ui_mask": {
                    "default": null,
                    "blank": true,
                    "dbName": "yqbase",
                    "tbName": "sys.sys_table",
                    "tempNo": -1,
                    "displayType": 1,
                    "valueMember": "sid",
                    "displayMember": "textbox",
                    "isPage": true,
                    "pageSize": 10,
                    "addWhere": "",
                    "order": "textbox",
                    "panelWidth": 400,
                    "panelHeight": 260,
                    "expandMember": null,
                    "seekNo": -1,
                    "seekModeW": 800,
                    "seekModeH": 600,
                    "mapping": [
                        {
                            "from": "textbox",
                            "to": "foreignkeyVal"
                        }]
                }
            }, {
                "is_func": false,
                "name": "foreignkeyVal",
                "ui_title": "foreignkeyVal",
                "ui_type": 2,
                "ui_width": 140,
                "ui_visible": true,
                "ui_readonly": false,
                "ui_mask": {
                }
            }];

        var mytree_2 = [
            {
                "no": 1,
                "name": "name-1",
                "date": "02/19/2010",
                "subs": [{
                    "no": 101,
                    "name": "name-101",
                    "date": "03/20/2010",
                    "subs": [{
                        "no": 10101,
                        "name": "name-10101",
                        "date": "01/13/2010",
                    }, {
                        "no": 10102,
                        "name": "name-10102",
                        "date": "02/26/2009"
                    }, {
                        "no": 10103,
                        "name": "name-10103",
                        "date": "02/26/2009"
                    }]
                }, {
                    "no": 102,
                    "name": "name-102",
                    "date": "01/20/2010",
                    "subs": [{
                        "no": 10201,
                        "name": "name-10201",
                        "size": "56 KB",
                        "date": "05/19/2009"
                    }, {
                        "no": 10202,
                        "name": "name-10202",
                        "date": "04/20/2010"
                    }, {
                        "no": 10203,
                        "name": "name-10203",
                        "date": "04/20/2010"
                    }]
                }]
            },
            {
                "no": 2,
                "name": "name-2",
                "date": "02/19/2010",
                "subs": [{
                    "no": 201,
                    "name": "name-201",
                    "date": "03/20/2010",
                    "subs": [{
                        "no": 20101,
                        "name": "name-20101",
                        "date": "01/13/2010",
                    }, {
                        "no": 20102,
                        "name": "name-20102",
                        "date": "02/26/2009"
                    }, {
                        "no": 20103,
                        "name": "name-20103",
                        "date": "02/26/2009"
                    }]
                }, {
                    "no": 202,
                    "name": "name-202",
                    "date": "01/20/2010",
                    "subs": [{
                        "no": 20201,
                        "name": "name-20201",
                        "size": "56 KB",
                        "date": "05/19/2009"
                    }, {
                        "no": 20202,
                        "name": "name-20202",
                        "date": "04/20/2010"
                    }, {
                        "no": 20203,
                        "name": "name-20203",
                        "date": "04/20/2010"
                    }]
                }]
            }
        ];
    </script>
</body>

</html>